<html>

<head>
  <script src="subresources/script.js"></script>
</head>

<body>
  <script type="text/javascript">

    // Returns the child frame url, which has path of the form
    // child_frame.html?case=|case_number|.
    function getChildFrameUrl(case_number, is_third_party) {
      var url = '';

      // Scheme.
      url += window.location.protocol + '//';

      // Host.
      url += is_third_party ?
        'third_party_host.com' : window.location.hostname;

      // Port.
      if (window.location.port)
        url += ':' + window.location.port;

      // Path.
      url += '/child_frame.html?case=' + case_number;

      return url;
    }

    function main() {
      // Append 4 pairs of iframes. Each pair with one first party and one
      // third party iframe. The iframes are named first_party_[1..4] and
      // third_party_[1..4].
      for (var i = 1; i <= 4; i++) {
        var first_party = document.createElement('iframe');
        first_party.src = getChildFrameUrl(i, false /*is_third_party*/);
        first_party.name = 'first_party_' + i;
        document.body.appendChild(first_party);

        var third_party = document.createElement('iframe');
        third_party.src = getChildFrameUrl(i, true /*is_third_party*/);
        third_party.name = 'third_party_' + i;
        document.body.appendChild(third_party);
      }
    }

    main();
  </script>
</body>

</html>
